﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Templates_Promotions_Default : Acms.AcmsControls.TemplatePage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (IsValid)
        {
            string emailToSendTo = "sales@elementskitchens.co.uk";
            string name = string.Concat(txtFirstName.Text, " ", txtSecondName.Text).Trim();
            var email = Acms.Bll.Email.CreateInstance(name, emailToSendTo, Server.MapPath("~/Emails/Promotion.xml"));

            email.Format("Promotion", AcmsContext.CurrentPost != null ? AcmsContext.CurrentPost.DisplayName : "PROMO NAME HERE");
            email.Format("FirstName", txtFirstName.Text);
            email.Format("SecondName", txtSecondName.Text);
            email.Format("Phone", txtPhone.Text);
            email.Format("EmailAddress", txtEmail.Text);
            email.Send();

            phConfirmation.Visible = true;
            phDetails.Visible = false;
        }
    }
}
